package
{
	import com.junkbyte.console.Cc;
	import com.junkbyte.console.KeyBind;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.getTimer;

	public class module1 extends Sprite
	{
		private var sprite:Sprite;

		public function module1()
		{
			Cc.debug("module1 init!");
			GameDispatcher.instance.dispatchEvent(new GameEvent(GameEvent.ADD_CYCLE_FUNCTION, "module1 Event!"));

			sprite = new Sprite();
			sprite.graphics.beginFill(0xff0000);
			sprite.graphics.drawCircle(50, 50, 50);
			sprite.graphics.endFill();

			GameDispatcher.instance.addEventListener("show_module1", onShow)

			GameDispatcher.instance.addEventListener("close_module1", onClose);
			
			Cc.bindKey(new KeyBind("r"), t);
		}

		private function onShow(event:Event):void
		{
			addChild(sprite);
			for (var i:int = 0; i < 10000; i++)
			{
				
			}
		}

		private function onClose(event:Event):void
		{
			if (sprite.parent)
			{
				removeChild(sprite);
			}
		}
		
		public function t():void
		{
			var startTime:int = getTimer();
			for (var i:int = 0; i < 100; i++)
			{
				onShow(null);
				onClose(null);
			}
			Cc.debug("module1花费：" + (getTimer() - startTime));
		}
	}
}
